package com.yyfax.pay.depository.controller.api;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yyfax.pay.depository.service.inner.ChangeUserInfoNotifyService;
import com.yyfax.pay.depository.service.inner.TradeNotifyService;
import com.yyfax.pay.third.model.to.fuioudeposit.ChangeUserInfoNotifyReq;
import com.yyfax.pay.third.model.to.fuioudeposit.EntrustTradeNotifyReq;
import com.yyfax.pay.third.model.to.fuioudeposit.TradeNotifyReq;
import com.yyfax.pay.third.model.to.fuioudeposit.WithdrawNotifyReq;

/**
 * 富友通知接口
 * 
 * @author heizq
 * @date 2017-09-02 18:22:48
 * @since v1.0.0
 */
@RestController
public class NotifyApiController {

	Logger logger = LoggerFactory.getLogger(getClass());
	@Resource
	private TradeNotifyService tradeNotifyService;

	@Resource
	private ChangeUserInfoNotifyService changeUserInfoNotifyService;

	/**
	 * 交易通知
	 * 
	 * @author heizq
	 * @date 2017-09-02 18:24:02
	 * @since v1.0.0
	 * @param req
	 * @return
	 */
	@PostMapping("/api/fuiou/trade/result/notify")
	public String tradeNotify(TradeNotifyReq req) {

		return tradeNotifyService.tradeNotify(req);
	}

	/**
	 * 委托提现异步回调-和通知有一些区别。地址是请求参数指定的back_notify_url
	 *
	 * @author yejc
	 * @date 2017-09-20
	 * @since v2.0.0
	 * @param req
	 * @return 成功就返回xml的字符串表示收到通知
	 */
	@PostMapping("/api/fuiou/entrust/withdraw/result/notify")
	public String entrustWithdrawNotify(EntrustTradeNotifyReq req) {
		return tradeNotifyService.handleEntrustWithdraw(req);
	}

	/**
	 * 委托充值异步回调-和通知有一些区别。地址是请求参数指定的back_notify_url
	 *
	 * @author yejc
	 * @date 2017-09-20
	 * @since v2.0.0
	 * @param req
	 * @return 成功就返回xml的字符串表示收到通知
	 */
	@PostMapping("/api/fuiou/entrust/charge/result/notify")
	public String entrustChargeNotify(EntrustTradeNotifyReq req) {
		return tradeNotifyService.handleEntrusCharge(req);
	}

	/**
	 * 提现退票通知接口
	 *
	 * @author yejc
	 * @date 2017-10-18
	 * @since v2.0.0
	 * @param req
	 * @return 成功就返回xml的字符串表示收到通知
	 */
	@PostMapping("/api/fuiou/withdraw/cancel/notify")
	public String withdrawCancelNotify(WithdrawNotifyReq req) {
		return tradeNotifyService.handleWithdrawCancel(req);
	}


	/**
	 * 用户修改信息通知
	 * 
	 * @author heizq
	 * @date 2017-09-02 18:24:02
	 * @since v1.0.0
	 * @param req
	 * @return
	 * @throws Exception
	 */
	@PostMapping(value = "/api/fuiou/change/user/info/notify")
	public String changeUserInfoNotify(@ModelAttribute ChangeUserInfoNotifyReq req) {
		return changeUserInfoNotifyService.changeUserInfoNotify(req);
	}
}
